package com.jinly.ryder.flow.dao.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.jinly.ryder.common.auth.model.AuthRole;
import com.jinly.ryder.common.auth.model.AuthType;
import com.jinly.ryder.common.dao.entity.BaseDO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;
import java.util.Map;


/**
 * 流程步骤
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "flow_step", autoResultMap = true)
public class FlowStepDO extends BaseDO {

    @TableId(type = IdType.AUTO)
    private Integer id;

    @TableField(value = "flow_rule_id")
    private Integer flowRuleId;

    @TableField(value = "need_invoke")
    private Boolean needInvoke;

    /**
     * 步骤名称
     */
    @TableField(value = "name")
    private String name;

    /**
     * 审批人条件
     */
    @TableField(value = "audit_condition", typeHandler = FastjsonTypeHandler.class)
    private AuditConditionDO auditCondition;

    @TableField(value = "next_step_map", typeHandler = FastjsonTypeHandler.class)
    private Map<String, String> nextStepMap;

    @Data
    public static class AuditConditionDO {
        private List<AuditUserConditionDO> userConditionList;
    }

    /**
     * 审批人条件
     */
    @Data
    public static class AuditUserConditionDO {
        /**
         * 权限类型
         */
        private AuthType authType;

        /**
         * 权限角色
         */
        private AuthRole authRole;
    }

}
